#pragma once

#include<iostream>
#include<string>
#include<ctime>


#define INFO 1
#define WARNING 2
#define ERROR 3
#define FATAL 4

#define LOG(level,message) Log(#level,message,__FILE__,__LINE__)


// void Log(std::string level,std::string message,std::string file_name,int line)
// {
//     std::cout<<"["<<level<<"]"
//     <<"["<<time(nullptr)<<"]"
//     <<"["<<message<<"]"
//     <<"["<<file_name<<"]"
//     <<"["<<line<<"]"
//     <<std::endl;
// }
void Log(std::string level, std::string message, std::string file_name, int line)
{
    // 获取当前时间戳并转成本地时间结构体
    std::time_t now = std::time(nullptr);
    std::tm* local_time = std::localtime(&now);

    // 格式化时间为字符串
    char time_buf[32];
    std::strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S", local_time);

    // 打印日志
    std::cout << "[" << level << "]"
              << "[" << time_buf << "]"
              << "[" << message << "]"
              << "[" << file_name << "]"
              << "[" << line << "]"
              << std::endl;
}
